package servlet;

import dao.UserDAO1;
import entity.User;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "cartPersonFindByName",value = "/cart/findByName")
public class CartPersonFindByNameS extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String name = request.getParameter("username");
        UserDAO1 dao = new UserDAO1();
        User user = dao.findByName(name);
        request.setAttribute("userId", user.getId());
        response.sendRedirect("/Mall/cart/userList?id="+user.getId());
    }
}
